<?php

class Login extends Base_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->model('Admin_user_model', 'admin_user');
        $this->load->model('Manager_model', 'manager');
    }

    public function index()
    {
        $login_status = $this->check_login_status();
        if (empty($login_status)) {
            $this->load->view('/common/admin_login');
        } else {
            redirect(BASEURL."/index");
        }
    }

    /**
     *
     */
    public function login_manager()
    {

        $username = $this->input->post('username', TRUE);
        $password = $this->input->post('password', TRUE);
        $arr_res  = $this->admin_user->check_account($username, $password);
        if ($arr_res['status'] == 0) {
            echo json_encode(array('code' => 0, 'page' => "index"));
        } else {
            echo json_encode(array('code' => -1, 'message' => $arr_res['message']));
        }
    }

    public function logout()
    {
        session_unset();
        session_destroy();
        $_SESSION['hy_admin_username'] = "";
        $_SESSION['hy_admin_id']       = "";
        $_SESSION['adminUserInfo']     = "";
        redirect(BASEURL . 'login');
    }
}
/* End of file login.php */
/* Location: ./application/controllers/luckydog/login.php */
